|
![](/i/fill.gif) |
In article <3BB37763.77E42F48@ignorancia.org> , Jaime Vives Piqueres
<jai### [at] ignorancia org> wrote:
> He, he... That's what a "real" programmer calls "good style". .. :)
I actually was referring to C/C++ as well as the assumption of short-circuit
evaluation in my original post.
> These are the kind of things I never come up myself (I don't consider my
> self a "real" programmer at all). But in my simplicity, I will like it
> more this way:
>
> #local i=0;
> #while (i<n)
> #if (a[i]!=0)
> #break
> #end
> #local n=n+1
> #end
>
> ...a pain it doesn't works, although I rarely need to use it with POV
> scripts.
Indeed the lack of a "break" statement in POV-Ray #while-loops makes the
problem and code more difficult than in C. So a bit more creative solutions
are needed. In C I would never use the above code as it will always be too
slow and just iterate through the array for no good reason. However, there
are might be more efficient ways to do in in POV-Ray as well (to cut down
parsing time).
By using the original search direction and a third variable it might well be
that there is a more efficient solution so parsing is faster if the above is
done on huge arrays with only a very few zeros. Of course, knowing why the
first non-zero element needs to be found would really help - knowing the
whole problem is almost always a good idea as it allows to look not only for
more efficient, but possible completely different solutions to the actual
problem...
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
![](/i/fill.gif) |